<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>候选人列表</title>  
</head>
<body>
<div class="ui segment" id="n-page">
<h3 class="ui header">
${job.name}
</h3>
公司：${company.name}<br>

&nbsp;<br>

<%--    <h3 class="ui attached header" id="list-title">--%>
<%--        候选人列表--%>
<%--    </h3>--%>
    <div class="ui attached segment" id="list-items">
    <c:forEach items="${recommends}" var="rd">
        <div class="ui segment listitem3">
            	候选人姓名：${rd.name}&nbsp;<br>&nbsp;<br>
            	<%-- 年龄：${rd.age}&nbsp;<br>&nbsp;<br> --%>
            	所在城市：${rd.cityName}&nbsp;<br>&nbsp;<br>
            	<%-- 联系电话：${rd.phone}&nbsp;<br>&nbsp;<br> --%>
        	  现任公司：
            <c:choose>
                <c:when test="${rd.companyid == 0 }">
                   	 ${rd.companyname}
                </c:when>
                <c:otherwise>
                    ${rd.companyname2}
                </c:otherwise>
            </c:choose> &nbsp;<br>&nbsp;<br>
            	现任职位：${rd.positionname}&nbsp;<br>&nbsp;<br>
            	<%-- 现任工作年限：${rd.workage}&nbsp;<br>&nbsp;<br> --%>
            面试结果：
            <c:choose>
                <c:when test="${rd.status == 0||rd.status == 1 }">
                   推荐中
                </c:when>
                <c:when test="${rd.status == 2 }">
                    推荐成功
                </c:when>
                <c:otherwise>
                    推荐失败
                </c:otherwise>
            </c:choose>
            <br>
        </div>
    </c:forEach>    
    </div>
    <br>&nbsp;

</div>
<!-- 测试用，正式发布关闭 -->
<!--
<div id="testid">
点击获取更多数据
</div>
-->

<input type="hidden" name="lastposition" id="lastcandidate" value="0"/>
<input type="hidden" name="hasmoredata" id="hasmoredata" value="no"/>

<script src="${ctx}/resources/jweixin-1.0.0.js"></script>

<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<!--
<script type="text/javascript" src="${ctx}/resources/semanticui/jquery.touchSwipe.min.js"></script>
-->
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'showOptionMenu']  
});

    var datasource = { 
        moredata: function() { 
            var getUrl = '${ctx}/wechat/headhunter/recommend/moreRecommend2.do?jobid=${job.id}';
            var offset  = $('#lastcandidate').val();
            var hasmore = $('#hasmoredata').val();

            getUrl += "&offset=" + offset;

            if(hasmore != "yes"){
                alert("已经没有更多数据了");
                return false;
            }
            var that = this;

            $.ajax({ 
                    url: getUrl, 
                    type: "GET", 
                    success: function(data, status){ 
                    	if(data.errorcode == 0) {
                    		that.appenddata(data);
                    	} else {
                    		var errorUrl = '${ctx}/wechat/candidate/error.page';
                    		location.href = errorUrl;
                    	}
                    }, 
                    error: function(){ 
                        alert("服务出错，请稍后尝试"); 
                    } 
            });
        },

        appenddata:function(data) { 
            var offset = parseInt($('#lastcandidate').val());
            var divstring = "";
            var recommends = data.recommends;

            var count = recommends.length;
            offset += parseInt(count);
            $('#lastcandidate').val(offset);
            if(count <10) {
                $('#hasmoredata').val('no');
            }

            for (var i in recommends) {
                var rd = recommends[i];

                divstring += '<div class="ui segment listitem3">';
                divstring += rd.name;
                if(rd.companyid == 0) {
                    divstring += rd.companyname;
                } else {
                    divstring += rd.companyname2;
                }
                divstring += rd.positionname;
                divstring += '<br>';
                divstring += '面试结果：';
                if(rd.status == 0||rd.status ==1) {
                    divstring += '推荐中';
                } else if(rd.status ==2) {
                    divstring += '推荐成功';
                } else {
                    divstring += '推荐失败';
                }
                divstring += '</div>';
            }
            var newdata = $(divstring);
            $('#list-items').append(newdata);
        }
    };

    $(document).ready(function() { 
        wx.ready(function() { 
            //$('#n-page').swipe({ 
            //    swipeUp:function(event, direction, distance, duration, fingerCount) { 
            //        datasource.moredata();
            //    } 
            //});

            $(window).scroll(function() { 
                if($(window).scrollTop() == $(document).height() - $(window).height()) {
                    datasource.moredata();
                } 
            });
        
            // $('#testid').on('click', function(){
            //     datasource.moredata();
            // });

<c:choose>
    <c:when test="${job.platformID == 2 }">
            wx.onMenuShareAppMessage({
                title: 'Headoffer--${job.name}--${job.reward} 元',  
                desc: '如果你或者你的朋友符合上面这个职位，那么就推荐给我们。推荐有奖，自荐有奖，奖、奖、奖。',  
                link: 'http://www.tiaonali.com${ctx}/wechat/hunter/sharejob.page?jobid=${job.id}',  
                imgUrl: 'http://www.tiaonali.com${ctx}/resources/images/sharelogo.jpg',  
                type: 'link'
            });

            wx.onMenuShareTimeline({
                title: 'Headoffer--${job.name}--${job.reward} 元',  
                desc: '如果你或者你的朋友符合上面这个职位，那么就推荐给我们。推荐有奖，自荐有奖，奖、奖、奖。',  
                link: 'http://www.tiaonali.com${ctx}/wechat/hunter/sharejob.page?jobid=${job.id}',  
                imgUrl: 'http://www.tiaonali.com${ctx}/resources/images/sharelogo.jpg'
            });
    </c:when>
    <c:otherwise>
            wx.onMenuShareAppMessage({
                title: '跳哪里--${job.name}--${job.reward} 元',  
                desc: '如果你或者你的朋友符合上面这个职位，那么就推荐给我们。推荐有奖，自荐有奖，奖、奖、奖。',  
                link: 'http://www.tiaonali.com/tn-candidate/wechat/candidate/sharejob.page?jobid=${job.id}',  
                imgUrl: 'http://www.tiaonali.com/tn-candidate/resources/images/sharelogo.jpg',  
                type: 'link'
            });

            wx.onMenuShareTimeline({
                title: '跳哪里--${job.name}--${job.reward} 元',  
                desc: '如果你或者你的朋友符合上面这个职位，那么就推荐给我们。推荐有奖，自荐有奖，奖、奖、奖。',  
                link: 'http://www.tiaonali.com/tn-candidate/wechat/candidate/sharejob.page?jobid=${job.id}',  
                imgUrl: 'http://www.tiaonali.com/tn-candidate/resources/images/sharelogo.jpg'
            });
    </c:otherwise>
</c:choose>



            wx.showOptionMenu();
        });
        
    });

</script>
</body>
</html>